// Upgrade NOTE: commented out 'float4x4 _World2Object', a built-in variable
// Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "Mobile/Bumped Specular" {
Properties {
 _Shininess ("Shininess", Range(0.03,1)) = 0.078125
 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" { }
 _BumpMap ("Normalmap", 2D) = "bump" { }
}
SubShader { 
 LOD 250
 Tags { "RenderType"="Opaque" }
 Pass {
  Name "FORWARD"
  Tags { "LIGHTMODE"="ForwardBase" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
  GpuProgramID 23179
CGPROGRAM
//#pragma target 4.0

#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"
#define conv_mxt4x4_0(mat4x4) float4(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x,mat4x4[3].x)
#define conv_mxt4x4_1(mat4x4) float4(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y,mat4x4[3].y)
#define conv_mxt4x4_2(mat4x4) float4(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z,mat4x4[3].z)
#define conv_mxt4x4_3(mat4x4) float4(mat4x4[0].w,mat4x4[1].w,mat4x4[2].w,mat4x4[3].w)


#define CODE_BLOCK_VERTEX
//uniform float3 _WorldSpaceCameraPos;
//uniform float4 _WorldSpaceLightPos0;
//uniform float4 unity_SHAr;
//uniform float4 unity_SHAg;
//uniform float4 unity_SHAb;
//uniform float4 unity_SHBr;
//uniform float4 unity_SHBg;
//uniform float4 unity_SHBb;
//uniform float4 unity_SHC;
//uniform float4x4 UNITY_MATRIX_MVP;
//uniform float4x4 unity_ObjectToWorld;
// uniform float4x4 _World2Object;
//uniform float4 unity_WorldTransformParams;
uniform float4 _MainTex_ST;
uniform float4 _LightColor0;
uniform sampler2D _MainTex;
uniform sampler2D _BumpMap;
uniform float _Shininess;
struct appdata_t
{
    float4 tangent :TANGENT;
    float4 vertex :POSITION;
    float3 normal :NORMAL;
    float4 texcoord :TEXCOORD0;
};

struct OUT_Data_Vert
{
    float2 xlv_TEXCOORD0 :TEXCOORD0;
    float4 xlv_TEXCOORD1 :TEXCOORD1;
    float4 xlv_TEXCOORD2 :TEXCOORD2;
    float4 xlv_TEXCOORD3 :TEXCOORD3;
    float3 xlv_TEXCOORD4 :TEXCOORD4;
    float3 xlv_TEXCOORD5 :TEXCOORD5;
    float4 vertex :SV_POSITION;
};

struct v2f
{
    float2 xlv_TEXCOORD0 :TEXCOORD0;
    float4 xlv_TEXCOORD1 :TEXCOORD1;
    float4 xlv_TEXCOORD2 :TEXCOORD2;
    float4 xlv_TEXCOORD3 :TEXCOORD3;
    float3 xlv_TEXCOORD4 :TEXCOORD4;
    float3 xlv_TEXCOORD5 :TEXCOORD5;
};

struct OUT_Data_Frag
{
    float4 color :SV_Target0;
};

OUT_Data_Vert vert(appdata_t in_v)
{
    OUT_Data_Vert out_v;
    float3 shlight_1;
    float tangentSign_2;
    float3 worldTangent_3;
    float3 worldNormal_4;
    float3 tmpvar_5;
    float3 tmpvar_6;
    tmpvar_6 = mul(unity_ObjectToWorld, in_v.vertex).xyz;
    float4 v_7;
    v_7.x = conv_mxt4x4_0(unity_WorldToObject).x;
    v_7.y = conv_mxt4x4_1(unity_WorldToObject).x;
    v_7.z = conv_mxt4x4_2(unity_WorldToObject).x;
    v_7.w = conv_mxt4x4_3(unity_WorldToObject).x;
    float4 v_8;
    v_8.x = conv_mxt4x4_0(unity_WorldToObject).y;
    v_8.y = conv_mxt4x4_1(unity_WorldToObject).y;
    v_8.z = conv_mxt4x4_2(unity_WorldToObject).y;
    v_8.w = conv_mxt4x4_3(unity_WorldToObject).y;
    float4 v_9;
    v_9.x = conv_mxt4x4_0(unity_WorldToObject).z;
    v_9.y = conv_mxt4x4_1(unity_WorldToObject).z;
    v_9.z = conv_mxt4x4_2(unity_WorldToObject).z;
    v_9.w = conv_mxt4x4_3(unity_WorldToObject).z;
    float3 tmpvar_10;
    tmpvar_10 = normalize((((v_7.xyz * in_v.normal.x) + (v_8.xyz * in_v.normal.y)) + (v_9.xyz * in_v.normal.z)));
    worldNormal_4 = tmpvar_10;
    float3x3 tmpvar_11;
    tmpvar_11[0] = conv_mxt4x4_0(unity_ObjectToWorld).xyz;
    tmpvar_11[1] = conv_mxt4x4_1(unity_ObjectToWorld).xyz;
    tmpvar_11[2] = conv_mxt4x4_2(unity_ObjectToWorld).xyz;
    float3 tmpvar_12;
    tmpvar_12 = normalize(mul(tmpvar_11, in_v.tangent.xyz));
    worldTangent_3 = tmpvar_12;
    float tmpvar_13;
    tmpvar_13 = (in_v.tangent.w * unity_WorldTransformParams.w);
    tangentSign_2 = tmpvar_13;
    float3 tmpvar_14;
    tmpvar_14 = (((worldNormal_4.yzx * worldTangent_3.zxy) - (worldNormal_4.zxy * worldTangent_3.yzx)) * tangentSign_2);
    float4 tmpvar_15;
    tmpvar_15.x = worldTangent_3.x;
    tmpvar_15.y = tmpvar_14.x;
    tmpvar_15.z = worldNormal_4.x;
    tmpvar_15.w = tmpvar_6.x;
    float4 tmpvar_16;
    tmpvar_16.x = worldTangent_3.y;
    tmpvar_16.y = tmpvar_14.y;
    tmpvar_16.z = worldNormal_4.y;
    tmpvar_16.w = tmpvar_6.y;
    float4 tmpvar_17;
    tmpvar_17.x = worldTangent_3.z;
    tmpvar_17.y = tmpvar_14.z;
    tmpvar_17.z = worldNormal_4.z;
    tmpvar_17.w = tmpvar_6.z;
    float3 tmpvar_18;
    tmpvar_18 = _WorldSpaceLightPos0.xyz;
    float4 tmpvar_19;
    tmpvar_19.w = 1;
    tmpvar_19.xyz = float3(worldNormal_4);
    float4 normal_20;
    normal_20 = tmpvar_19;
    float3 res_21;
    float3 x_22;
    x_22.x = dot(unity_SHAr, normal_20);
    x_22.y = dot(unity_SHAg, normal_20);
    x_22.z = dot(unity_SHAb, normal_20);
    float3 x1_23;
    float4 tmpvar_24;
    tmpvar_24 = (normal_20.xyzz * normal_20.yzzx);
    x1_23.x = dot(unity_SHBr, tmpvar_24);
    x1_23.y = dot(unity_SHBg, tmpvar_24);
    x1_23.z = dot(unity_SHBb, tmpvar_24);
    res_21 = (x_22 + (x1_23 + (unity_SHC.xyz * ((normal_20.x * normal_20.x) - (normal_20.y * normal_20.y)))));
    float _tmp_dvx_149 = max(((1.055 * pow(max(res_21, float3(0, 0, 0)), float3(0.4166667, 0.4166667, 0.4166667))) - 0.055), float3(0, 0, 0));
    res_21 = float3(_tmp_dvx_149, _tmp_dvx_149, _tmp_dvx_149);
    shlight_1 = res_21;
    tmpvar_5 = shlight_1;
    out_v.vertex = UnityObjectToClipPos(in_v.vertex);
    out_v.xlv_TEXCOORD0 = TRANSFORM_TEX(in_v.texcoord.xy, _MainTex);
    out_v.xlv_TEXCOORD1 = tmpvar_15;
    out_v.xlv_TEXCOORD2 = tmpvar_16;
    out_v.xlv_TEXCOORD3 = tmpvar_17;
    out_v.xlv_TEXCOORD4 = normalize((normalize((_WorldSpaceCameraPos - tmpvar_6)) + normalize(tmpvar_18)));
    out_v.xlv_TEXCOORD5 = tmpvar_5;
    return out_v;
}

#define CODE_BLOCK_FRAGMENT
OUT_Data_Frag frag(v2f in_f)
{
    OUT_Data_Frag out_f;
    float3 worldN_1;
    float4 c_2;
    float3 worldViewDir_3;
    float3 lightDir_4;
    float3 tmpvar_5;
    tmpvar_5 = _WorldSpaceLightPos0.xyz;
    lightDir_4 = tmpvar_5;
    float3 tmpvar_6;
    tmpvar_6 = normalize(in_f.xlv_TEXCOORD4);
    worldViewDir_3 = tmpvar_6;
    float4 tmpvar_7;
    tmpvar_7 = tex2D(_MainTex, in_f.xlv_TEXCOORD0);
    float3 tmpvar_8;
    tmpvar_8 = ((tex2D(_BumpMap, in_f.xlv_TEXCOORD0).xyz * 2) - 1);
    c_2.w = 0;
    float tmpvar_9;
    tmpvar_9 = dot(in_f.xlv_TEXCOORD1.xyz, tmpvar_8);
    worldN_1.x = tmpvar_9;
    float tmpvar_10;
    tmpvar_10 = dot(in_f.xlv_TEXCOORD2.xyz, tmpvar_8);
    worldN_1.y = tmpvar_10;
    float tmpvar_11;
    tmpvar_11 = dot(in_f.xlv_TEXCOORD3.xyz, tmpvar_8);
    worldN_1.z = tmpvar_11;
    c_2.xyz = (tmpvar_7.xyz * in_f.xlv_TEXCOORD5);
    float4 c_12;
    float spec_13;
    float tmpvar_14;
    tmpvar_14 = max(0, dot(worldN_1, worldViewDir_3));
    float tmpvar_15;
    tmpvar_15 = (pow(tmpvar_14, (_Shininess * 128)) * tmpvar_7.w);
    spec_13 = tmpvar_15;
    c_12.xyz = (((tmpvar_7.xyz * _LightColor0.xyz) * max(0, dot(worldN_1, lightDir_4))) + (_LightColor0.xyz * spec_13));
    c_12.w = 1;
    c_2.xyz = (c_2 + c_12).xyz;
    c_2.w = 1;
    out_f.color = c_2;
    return out_f;
}


ENDCG

}
}
Fallback "Mobile/VertexLit"
}